import os
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QListView, QPushButton, QLabel

class WinRARStyleFileManager(QWidget):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("WinRAR Style File Manager")
        self.setGeometry(100, 100, 800, 600)

        self.current_path = "/"  # 当前路径

        # 创建文件列表视图
        self.file_list_view = QListView(self)
        self.file_list_model = self.create_file_list_model(self.current_path)
        self.file_list_view.setModel(self.file_list_model)

        # 创建返回按钮
        self.back_button = QPushButton("Back", self)
        self.back_button.clicked.connect(self.go_up)

        # 创建当前路径标签
        self.path_label = QLabel(self.current_path, self)

        # 设置布局
        layout = QVBoxLayout(self)
        layout.addWidget(self.back_button)
        layout.addWidget(self.path_label)
        layout.addWidget(self.file_list_view)

    def create_file_list_model(self, path):
        file_list = [".."] + os.listdir(path)
        return file_list

    def go_up(self):
        if self.current_path != "/":
            self.current_path = os.path.dirname(self.current_path)
            self.update_file_list()

    def update_file_list(self):
        self.file_list_model = self.create_file_list_model(self.current_path)
        self.file_list_view.setModel(self.file_list_model)
        self.path_label.setText(self.current_path)

if __name__ == "__main__":
    app = QApplication([])
    winrar_style_file_manager = WinRARStyleFileManager()
    winrar_style_file_manager.show()
    app.exec_()
